package org.lanqiao.tjut.chengxu02;

import java.util.Scanner;

import org.junit.Test;

public class Sushu {
	/*
	 * 素数的属性
	 */
	private int i;

	// 判断行为
	public void dotf() {
		int i;
		Scanner input = new Scanner(System.in);
		System.out.println("请输入一个大于2的数");
		i = input.nextInt();
		System.out.println("2到" + i + "之间质数为：");
		int b=0,c=0,k;
		
		for (int a=2; a <=i; a++) {
		boolean iFlag = true;
		
			for (int j = 2; j <= Math.sqrt(a); j++) {
				if (a % j == 0) {
					b++;
					c=b;
					iFlag = false;
					break;
				}

			}
			if(iFlag){
				System.out.print(" "+a);
			}
		}
		k=i-1-c;
		System.out.println();
		System.out.println("共"+k+"个质数");
	
	}


	public int getI() {
		return i;
	}

	public void setI(int i) {
		this.i = i;
	}
	@Test
	public void dotf2() {
		int i;
		Scanner input = new Scanner(System.in);
		System.out.println("请输入一个大于2的数");
		i = input.nextInt();
		System.out.println("2到" + i + "之间质数为：");
		int k=0;
		
		for (int a=2; a <=i; a++) {
		boolean iFlag = true;
		
			for (int j = 2; j <= Math.sqrt(a); j++) {
				if (a % j == 0) {
					iFlag = false;
					break;
				}
			}
			if(iFlag){
				k++;
				System.out.print(" "+a);
			}
		}
		System.out.println();
		System.out.println("共"+k+"个质数");
	
	}
}
